#ifndef __WIDGETWIN_H_
#define __WIDGETWIN_H_
#include <memory>
#include <thread>

class SkCanvas;
class Layout;
class RootView;
class FocusManager;
class EventManager;

class WidgetWin
{
public:
	WidgetWin();
	virtual ~WidgetWin();

public:
	bool createWindow(HINSTANCE hInstance, int nCmdShow);
	LRESULT OnWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

	static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
	static void thread_fun(std::string str);

	inline unsigned int width() { return m_width; }
	inline unsigned int height() { return m_height;  }

	bool init();
	bool deinit();

	static WidgetWin& getInstance()
	{
		static WidgetWin widget;
		return widget;
	}

	HWND getNativeHwnd()
	{
		return m_wnd;
	}

	RootView* getRootView()
	{
		return m_rootView;
	}

	FocusManager* getFocusManager()
	{
		return m_focusManager;
	}

private:
	HWND m_wnd;


	SkCanvas* canvas_;
	// SkCanvas* m_canvas;
	static WidgetWin& m_widget;
	// Layout* m_layout;

	unsigned int m_width;
	unsigned int m_height;

	RootView* m_rootView;

	// caption mouse
	bool m_isCaption;

	FocusManager* m_focusManager;

	EventManager* m_eventManager;

	ULONG_PTR	m_gdiplusToken;

	std::thread* work_thread_;

};

#endif // !__WIDGETWIN_H_